// 富文本处理
function richTextFun(html){
	let newContent = ''
	newContent = html.replace(/<img[^>]*>/gi,
		function(match) {
			match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
			match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
			match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
			return match;
		});
	newContent = newContent.replace(/style="[^"]+"/gi,
		function(match) {
			match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
				'max-width:100%;');
			return match;
		});
	newContent = newContent.replace(/<br[^>]*\/>/gi, '');
	newContent = newContent.replace(/\<img/gi,
		'<img style="max-width:100%;height:auto;display:inline-block;margin:-15rpx auto;"');
	newContent = newContent.replace(/\<p/gi,
		'<p style="line-height: 38rpx;" ');
	return newContent;
}

// 时间处理
function timeFun(time,fmt){
	time = new Date(time)
	var o = {
		"M+": time.getMonth() + 1, //月份
		"D+": time.getDate(), //日
		"h+": time.getHours(), //小时
		"m+": time.getMinutes(), //分
		"s+": time.getSeconds(), //秒
		"q+": Math.floor((time.getMonth() + 3) / 3), //季度
		"S": time.getMilliseconds() //毫秒
	};
	if (/(Y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (time.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o) {
		if (new RegExp("(" + k + ")").test(fmt)) {
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k])
				.length)));
		}
	
	}
	return fmt;
}

// 电话号处理 中间4位隐藏
function phoneFun(phone){
	return phone.replace(phone.slice(3,7),'****')
}




export { richTextFun , timeFun , phoneFun }

